//
//  LyBaseNavigationController.swift
//  SinaWeibo
//
//  Created by 蒋琪 on 2017/5/24.
//  Copyright © 2017年 liuying. All rights reserved.
//

import UIKit

class LyBaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

    
    
    //MARK: -
    //MARK: - 重写push方法
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        let  count = childViewControllers.count
        if count > 0 {
            
        viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(normalImg: "navigationbar_back_withtext", highlightedImg: "navigationbar_back_withtext_highlighted", target: self, action: #selector(backClick), title: "返回")
            //当进入子页面的时候隐藏底部的TabBar
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
        
        
    }
    
    
    @objc private func backClick(){
    
        self.popViewController(animated: true)
    }
}
